﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="GoodsList.aspx.cs" Inherits="Project_Udrinkwater.PagesAdmin.GoodsList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <dx:ASPxRoundPanel ID="RPN_GoodsList" runat="server" Width="100%" 
        HeaderText="รายการสินค้า">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
     <dx:ASPxButton ID="bt_AddGoods" runat="server" Text="เพิ่มสินค้า" 
            onclick="bt_AddGoods_Click" Theme="Youthful">
        </dx:ASPxButton>
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" KeyFieldName="Product_ID" 
        onrowcommand="ASPxGridView1_RowCommand" Width="100%" Font-Size="Small">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="Product_ID" ReadOnly="True" 
                VisibleIndex="0" Caption="รหัสสินค้า">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Product_Name" VisibleIndex="1" 
                Caption="รายละเอียดสินค้า">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataImageColumn FieldName="Image" VisibleIndex="3" Caption="สินค้า">
                <PropertiesImage ImageHeight="120px" ImageWidth="100px">
                </PropertiesImage>
            </dx:GridViewDataImageColumn>
            <dx:GridViewDataTextColumn VisibleIndex="2" FieldName="Unit_Name" 
                Caption="หน่วยการขาย">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn VisibleIndex="4" Width="230px">
                <DataItemTemplate>
                    <asp:LinkButton ID="lb_Edit" runat="server" ForeColor="#80A70E" 
                        CommandName="Cmdedit" CommandArgument='<%# Eval("Product_ID") %>' >แก้ไขข้อมูลสินค้า</asp:LinkButton>
                    &nbsp;
                    <asp:LinkButton ID="lb_Delete" runat="server" ForeColor="#80A70E" CommandName="Cmddelete" CommandArgument='<%# Eval("Product_ID") %>' >ลบข้อมูลสินค้า
                     <ClientSideEvents Click="function(s,e) { e.processOnServer = confirm('ยืนยันการลบข้อมูลสินค้า?'); }" />
                    </asp:LinkButton>
                </DataItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
        </Columns>
          
            <SettingsPager Mode="ShowAllRecords">
            </SettingsPager>
          
            <SettingsDetail ShowDetailRow="True" />
            <Templates>
                <DetailRow>
                    <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="SqlDataSource_Price" Width="100%" 
                        KeyFieldName="Order_Category_ID" 
                        onbeforeperformdataselect="detailGrid_DataSelect">
                        <Columns>
                            <dx:GridViewDataTextColumn FieldName="Order_Category_Name" VisibleIndex="0" 
                                Caption="ประเภทการขาย">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Price" VisibleIndex="1" Caption="ราคา">
                            </dx:GridViewDataTextColumn>
                        </Columns>
                    </dx:ASPxGridView>
                    <asp:SqlDataSource ID="SqlDataSource_Price" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                        SelectCommand="SELECT [Order_Category_Name], [Price] FROM [TB_Order_Category] WHERE ([Product_ID] = @Product_ID)">
                        <SelectParameters>
                            <asp:SessionParameter Name="Product_ID" SessionField="Product_ID" 
                                Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </DetailRow>
            </Templates>
          
    </dx:ASPxGridView>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        
        SelectCommand="SELECT TB_Product.Product_ID, TB_Product.Product_Name, TB_Product.Image, TB_Unit_Category.Unit_Name FROM TB_Product INNER JOIN TB_Unit_Category ON TB_Product.Product_Unit = TB_Unit_Category.Unit_ID
ORDER BY id DESC"></asp:SqlDataSource>
</dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
    
    </asp:Content>
